<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // num.toFixed()
        // 作用：四舍五入，保留小数位数。
        const num = 10.929
        const res = num.toFixed(2)  // 注意，返回的是string
        console.log(res)

        // 如果不传参数, 四舍五入为整数形式的字符串
        const res2 = num.toFixed()
        console.log(res2)
    </script>
</body>
</html>